//
//  PWPTrustedWiFiListViewController.swift
//  TestPwp
//
//  Created by Denny on 2018/11/29.
//  Copyright © 2018 Denny. All rights reserved.
//

import Cocoa

class PWPTrustedWiFiListViewController: NSViewController,NSTableViewDelegate,NSTableViewDataSource {

    fileprivate enum CellIdentifiers {
        static let CheckImageCell = "CheckImageCellID"
        static let TrustedCell = "TrustedCellID"
        static let ListCell = "ListCellID"
    }
    
    @IBOutlet weak var tableView: NSTableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do view setup here.
    }
    
    public func numberOfRows(in tableView: NSTableView) -> Int {
        return 10;
    }
    
    public func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
        
        var cellIdentifier: String = ""
        
        // 2
        if tableColumn == tableView.tableColumns[0] {
//            image = item.icon
//            text = item.name
            cellIdentifier = CellIdentifiers.CheckImageCell
            
            if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: nil) as? NSTableCellView {
                
                print(cellIdentifier);
                
            }
            
        } else {
            
            if tableColumn == tableView.tableColumns[1] {
                //            text = dateFormatter.string(from: item.date)
                cellIdentifier = CellIdentifiers.TrustedCell
            } else if tableColumn == tableView.tableColumns[2] {
                //            text = item.isFolder ? "--" : sizeFormatter.string(fromByteCount: item.size)
                cellIdentifier = CellIdentifiers.ListCell
            }
            
            if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: nil) as? NSTableCellView {
                //            cell.isHidden = true;
                
//                cell.textField?.maximumNumberOfLines = 2;
                cell.textField?.usesSingleLineMode = true;
                cell.textField?.stringValue = "%SSID%";
                return cell;
            }
        }
        return nil;
    }
    
    @IBAction func cancelAction(_ sender: Any) {
        
        self.dismiss(nil);
    }
}
